package com.text.day1_5;

public class Cat {
    String ping;
    String color;
    int age;
    String name;
    char sex;
    int san;
    int height;
    public Cat(){

    }
    public Cat(String name){
        this.name = name;
    }

    public Cat(String ping, String color, int age, String name, char sex, int san, int height) {
        this(name);   // 这个还必须要写在第一行
        this.ping = ping;
        this.color = color;
        this.age = age;
//        this.name = name;

        this.sex = sex;
        this.san = san;
        this.height = height;
    }

    public void eat(){
        this.san++;
        this.height++;
    }

    public void sleep(){
        this.san += 10;

    }
    public void cathFish(){
        this.san++;
        this.height -= 10;
    }
    public void fanBehand(){
        this.height--;
        this.san++;
    }
    public void sortMao(int[] a){      //从小到大
        for (int i = 0; i < a.length - 1; i++) {
            for (int j = 0; j < a.length - i; j++) {
                if(a[j] > a[j + 1]){
                    int h = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = h;
                }
            }
        }
    }

    @Override             //这是方法的覆盖
    public String toString() {      // 有了这个就可以直接sout对象
        return "Cat{" +
                "ping='" + ping + '\'' +
                ", color='" + color + '\'' +
                ", age=" + age +
                ", name='" + name + '\'' +
                ", sex=" + sex +
                ", san=" + san +
                ", height=" + height +
                '}';
    }
}
